package com.woniuxy;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.CrossOrigin;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@SpringBootApplication
@EnableTransactionManagement
@MapperScan("com.woniuxy.mapper")
@EnableSwagger2
@CrossOrigin
public class DefectsApplication {

    public static void main(String[] args) {
        SpringApplication.run(DefectsApplication.class, args);
    }

    @Bean
    public Docket createRestApi() {

        ApiInfoBuilder apiBuilder = new ApiInfoBuilder();
        apiBuilder.title("缺陷处理系统");
        apiBuilder.description("分配处理系统缺陷");
        apiBuilder.contact(new Contact("XXXX","www.woniuxy.com","dengqiang@woniuxy.com"));
        apiBuilder.version("1.0");

        ApiInfo api = apiBuilder.build();

        Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(api);

        docket.select().apis(RequestHandlerSelectors.basePackage("com.woniuxy.controller")).paths(PathSelectors.any()).build();
        return docket;
    }

}
